package com.industrial.premu.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.industrial.common.log.annotation.Log;
import com.industrial.common.log.enums.BusinessType;
import com.industrial.common.security.annotation.RequiresPermissions;
import com.industrial.premu.domain.PreMuReject;
import com.industrial.premu.service.IPreMuRejectService;
import com.industrial.common.core.web.controller.BaseController;
import com.industrial.common.core.web.domain.AjaxResult;
import com.industrial.common.core.utils.poi.ExcelUtil;
import com.industrial.common.core.web.page.TableDataInfo;

/**
 * 否决项Controller
 * 
 * @author ZhouS
 * @date 2024-01-24
 */
@RestController
@RequestMapping("/reject")
public class PreMuRejectController extends BaseController
{
    @Autowired
    private IPreMuRejectService preMuRejectService;

    /**
     * 查询否决项列表
     */
    @RequiresPermissions("premu:reject:list")
    @GetMapping("/list")
    public TableDataInfo list(PreMuReject preMuReject)
    {
        startPage();
        List<PreMuReject> list = preMuRejectService.selectPreMuRejectList(preMuReject);
        return getDataTable(list);
    }

    /**
     * 导出否决项列表
     */
    @RequiresPermissions("premu:reject:export")
    @Log(title = "否决项", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PreMuReject preMuReject)
    {
        List<PreMuReject> list = preMuRejectService.selectPreMuRejectList(preMuReject);
        ExcelUtil<PreMuReject> util = new ExcelUtil<PreMuReject>(PreMuReject.class);
        util.exportExcel(response, list, "否决项数据");
    }

    /**
     * 获取否决项详细信息
     */
    @RequiresPermissions("premu:reject:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return success(preMuRejectService.selectPreMuRejectById(id));
    }

    /**
     * 新增否决项
     */
    @RequiresPermissions("premu:reject:add")
    @Log(title = "否决项", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PreMuReject preMuReject)
    {
        return toAjax(preMuRejectService.insertPreMuReject(preMuReject));
    }

    /**
     * 修改否决项
     */
    @RequiresPermissions("premu:reject:edit")
    @Log(title = "否决项", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PreMuReject preMuReject)
    {
        return toAjax(preMuRejectService.updatePreMuReject(preMuReject));
    }

    /**
     * 删除否决项
     */
    @RequiresPermissions("premu:reject:remove")
    @Log(title = "否决项", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(preMuRejectService.deletePreMuRejectByIds(ids));
    }
}
